/*
 * LCD1602 IIC驱动
 */
#ifndef LCD1602A_H
#define LCD1602A_H

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include "component_bmp280.h"
 
LiquidCrystal_I2C lcd(0x27,16,2);  //配置LCD地址及行列
 
void display_bmp280_d() {
  lcd.setCursor(3,0); 
  lcd.print(String(temperature, 1));
  lcd.setCursor(10,0); 
  lcd.print(String(pressure, 1));
  lcd.setCursor(11,1);//设置显示位置
  lcd.print(String(distance_cm, 0)); 
  lcd.print("   ");
}

void setup_lcd(){
  lcd.init(); //初始化LCD
  lcd.backlight(); //打开背光
  lcd.setCursor(0,0);//设置显示位置
  lcd.print("Welcome To");//显示字符数据
  lcd.setCursor(0,1);//设置显示位置
  lcd.print(" Arduino World");//显示字符数据
  delay(1000);
  lcd.clear();
  lcd.setCursor(1,0); 
  lcd.print("T:");
  lcd.setCursor(7,0); 
  lcd.print(" P:");
  lcd.setCursor(0,1);
  lcd.print(" Distance:");
}
 
void loop_lcd()
{
  display_bmp280_d();
}

#endif /* LCD1602A_H */